package fps;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

public class MainGUI extends JFrame implements ActionListener, KeyListener{
	private static final long serialVersionUID = 9064171320319392205L;
	
	public GameScreen display;
	public Player Jim;

	public boolean up = false, down = false, left = false, right = false;

	public MainGUI(){
		super("Shot down");
		this.setExtendedState(JFrame.MAXIMIZED_BOTH);
		this.setSize(500,500);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		
		this.addKeyListener(this);
		
		Jim = new Player(10,10,0);	
		display = new GameScreen(Jim, this);
		this.add(display);
		
		this.runGame();
	}

	private void runGame() {
		while(true){
			display.updateGame();
		}
		
	}

	@Override
	public void actionPerformed(ActionEvent ae) {
		//if(ae.getSource()==)
	}
	
	
	public static void main(String[] args) {new MainGUI();}

	@Override
	public void keyPressed(KeyEvent ke) {
		if(ke.getKeyCode() == (KeyEvent.VK_UP)){
			up  = true;
		}
		if(ke.getKeyCode() == (KeyEvent.VK_DOWN)){
			down = true;
		}
		if(ke.getKeyCode() == (KeyEvent.VK_LEFT)){
			left = true;
		}
		if(ke.getKeyCode() == (KeyEvent.VK_RIGHT)){
			right = true;
		}
		
	}

	@Override
	public void keyReleased(KeyEvent ke) {
		if(ke.getKeyCode() == (KeyEvent.VK_UP)){
			up  = false;
		}
		if(ke.getKeyCode() == (KeyEvent.VK_DOWN)){
			down = false;
		}
		if(ke.getKeyCode() == (KeyEvent.VK_LEFT)){
			left = false;
		}
		if(ke.getKeyCode() == (KeyEvent.VK_RIGHT)){
			right = false;
		}
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
